package io.renren.imooc.socket;

import com.xiaoleilu.hutool.io.IoUtil;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

/**
 * 服务器线程处理类
 * Created by kun on 2017/5/2.
 */
public class ServerThread extends Thread{
    Socket socket=null;

    public ServerThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        InputStream is=null;
        try {
            is = socket.getInputStream();
            System.out.println("我是server,client说:"+ IoUtil.read(is));
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (is!=null){
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }
    }
}
